﻿// Decompiled with JetBrains decompiler
// Type: UnityEngine.Serialization.UnitySurrogateSelector
// Assembly: UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: E6AE6B5A-2752-4B07-9528-C8B77C62CE79
// Assembly location: C:\Users\windys\Unity\2021.3.39f1c1\Editor\Data\Managed\UnityEngine\UnityEngine.CoreModule.dll
// XML documentation location: C:\Users\windys\Unity\2021.3.39f1c1\Editor\Data\Managed\UnityEngine\UnityEngine.CoreModule.xml

using System;
using System.Collections.Generic;
using System.Runtime.Serialization;

#nullable disable
namespace UnityEngine.Serialization
{
  public class UnitySurrogateSelector : ISurrogateSelector
  {
    public ISerializationSurrogate GetSurrogate(
      System.Type type,
      StreamingContext context,
      out ISurrogateSelector selector)
    {
      if (type.IsGenericType)
      {
        System.Type genericTypeDefinition = type.GetGenericTypeDefinition();
        if (genericTypeDefinition == typeof (List<>))
        {
          selector = (ISurrogateSelector) this;
          return ListSerializationSurrogate.Default;
        }
        if (genericTypeDefinition == typeof (Dictionary<,>))
        {
          selector = (ISurrogateSelector) this;
          return (ISerializationSurrogate) Activator.CreateInstance(typeof (DictionarySerializationSurrogate<,>).MakeGenericType(type.GetGenericArguments()));
        }
      }
      selector = (ISurrogateSelector) null;
      return (ISerializationSurrogate) null;
    }

    public void ChainSelector(ISurrogateSelector selector) => throw new NotImplementedException();

    public ISurrogateSelector GetNextSelector() => throw new NotImplementedException();
  }
}
